<template>
  <div class="printForm">
    <div class="area-header">
      <span class="area-header-title">{{ $t('申请单') }}</span>
    </div>
    <table class="printTable">
      <tr>
        <td class="tit">{{ $t('流水号') }}</td>
        <td>{{ form.serialNumber }}</td>
        <td class="tit">{{ $t('开放控制') }}</td>
        <td>
          <dict-select
            v-model="form.openControl"
            dictionary="open_control"
            :is-echo="true"
            :placeholder="$t('开放控制')"
          />
        </td>
      </tr>
      <tr>
        <td class="tit">{{ $t('密级') }}</td>
        <td>
          <dict-select
            v-model="form.securityClassification"
            dictionary="security_classification"
            :is-echo="true"
            :placeholder="$t('密级')"
          />
        </td>
        <td class="tit">{{ $t('缓急') }}</td>
        <td>
          <dict-select
            v-model="form.gradual"
            dictionary="gradual"
            :is-echo="true"
            :placeholder="$t('缓急')"
          />
        </td>
      </tr>
      <tr>
        <td class="tit">{{ $t('主送领导') }}</td>
        <td>
          <UserSelect
            v-model="form.userId"
          />
        </td>
        <td class="tit">{{ $t('部门主表') }}</td>
        <td>
          <UserSelect
            v-model="form.departmentManager"
          />
        </td>
      </tr>
      <tr>
        <td class="tit">{{ $t('部门负责人') }}</td>
        <td> <UserSelect v-model="form.departmentHead" /></td>
      </tr>
      <tr>
        <td class="tit">{{ $t('发文标题') }}</td>
        <td colspan="3">{{ form.actTitle }}</td>
      </tr>
      <tr>
        <td class="tit">{{ $t('内容概要') }}</td>
        <td colspan="3">{{ form.contentOutline }}</td>
      </tr>
      <tr>
        <td class="tit">{{ $t('主送单位') }}</td>
        <td>{{ form.lordSendUnit }}</td>
        <td class="tit">{{ $t('抄报单位') }}</td>
        <td>{{ form.sendAUnit }}</td>
      </tr>
      <tr>
        <td class="tit">{{ $t('抄送单位') }}</td>
        <td>{{ form.ccUnit }}</td>
        <td class="tit">{{ $t('内部发送') }}</td>
        <td>{{ form.internalSend }}</td>
      </tr>
      <tr>
        <td class="tit">{{ $t('发文类别') }}</td>
        <td>
          <dict-select
            v-model="form.postCategory"
            dictionary="post_category"
            :is-echo="true"
            :placeholder="$t('发文类别')"
          />
        </td>
        <td class="tit">{{ $t('发文编号') }}</td>
        <td>{{ form.postCode }}</td>
      </tr>
      <tr>
        <td class="tit">{{ $t('可知悉的岗位或级别') }}</td>
        <td>{{ form.canLearnPost }}</td>
        <td class="tit">{{ $t('校对') }}</td>
        <td>{{ form.proofread }}</td>
      </tr>
      <tr>
        <td class="tit">{{ $t('打印份数') }}</td>
        <td>{{ form.copies }}</td>
        <td class="tit">{{ $t('触发日期') }}</td>
        <td>{{ parseTime(form.triggerDate) }}</td>
      </tr>
      <tr>
        <td class="tit">{{ $t('是否用印') }}</td>
        <td colspan="3">
          {{ selectDictLabel(isSealOptions, form.isSeal) }}
        </td>
      </tr>
      <tr>
        <td class="tit">{{ $t('发文类型') }}</td>
        <td>
          <dict-select
            v-model="form.postType"
            dictionary="sign_type"
            :is-echo="true"
            :placeholder="$t('发文类型')"
          />
        </td>
        <td class="tit">{{ $t('关联项目') }}</td>
        <td>
          <el-select v-model="form.dealId" multiple filterable :placeholder="$t('关联项目')" clearable>
            <el-option
              v-for="item in dealBaseList"
              :key="item.id"
              :label="item.dealName"
              :value="item.id"
            />
          </el-select>
        </td>
      </tr>
      <tr>
        <td class="tit">{{ $t('备注') }}</td>
        <td colspan="3">{{ form.remark }}</td>
      </tr>
    </table>
    <!-- 附件列表 -->
    <FileView :list.sync="form.fileList" data-type="oa_lnitiate_post" :btn-show="!otherBtnHide" />

  </div>

</template>

<script>
  import { getOaLnitiatePost } from '@/api/oa/lnitiatePost/oaLnitiatePost'
  import { findDeal } from '@/api/base/deal/dealBase'

  export default {
    name: 'OaLnitiatePostForm',
    components: {
    },
    data() {
      return {
        openLocation: undefined,
        // 是否隐藏保存按钮
        btnHide: false,
        // 是否隐藏其它按钮
        otherBtnHide: false,
        // 表单参数
        form: {
          // 附件列表
          fileList: []
        },
        // 遮罩层
        loading: false,
        // 操作按钮默认不展示
        buttonShow: true,
        isSealOptions: [],
        openControlOptions: [],
        securityClassificationOptions: [],
        gradualOptions: [],
        signTypeOptions: [],
        actStatusOptions: [],
        postTypeOptions: [],
        dealBaseList: []
      }
    },
    created() {
      this.getDicts('open_control').then(response => {
        this.openControlOptions = response.data
      })
      this.getDicts('security_classification').then(response => {
        this.securityClassificationOptions = response.data
      })
      this.getDicts('gradual').then(response => {
        this.gradualOptions = response.data
      })
      this.getDicts('post_category').then(response => {
        this.postCategoryOptions = response.data
      })
      this.getDicts('sys_yes_no').then(response => {
        this.isSealOptions = response.data
      })
      this.getDicts('sign_type').then(response => {
        this.postTypeOptions = response.data
      })
      // 查询项目
      findDeal().then(res => {
        this.dealBaseList = res.data
      })
      this.$bus.$emit('async_done')
    },
    methods: {
      // 初始化数据
      init(data) {
        this.loading = true
        if (data != null && data.id !== undefined && data.id !== '' && data.id !== null) {
          this.buttonShow = false
          // 根据ID查询数据
          getOaLnitiatePost(data.id).then(response => {
            this.form = response.data
            this.loading = false
          })
        }
      }

    }

  }
</script>

